package com.cmas.platform.config;

import com.cmas.platform.config.sensitiveWord.BlacklistWord;
import com.cmas.platform.config.sensitiveWord.WhitelistWord;
import com.github.houbb.sensitive.word.bs.SensitiveWordBs;
import com.github.houbb.sensitive.word.support.allow.WordAllows;
import com.github.houbb.sensitive.word.support.deny.WordDenys;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author su
 * @Date 2023/4/14 16:13
 */
@Configuration
public class SensitiveWordConfig {
    @Autowired
    private BlacklistWord blacklistWord;

    @Autowired
    private WhitelistWord whitelistWord;


    /**
     * 初始化引导类
     * @return 初始化引导类
     * @since 1.0.0
     */
    @Bean
    public SensitiveWordBs sensitiveWordBs() {
        return SensitiveWordBs.newInstance()
                .wordAllow(WordAllows.chains(WordAllows.system(), whitelistWord))
                .wordDeny(WordDenys.chains(WordDenys.system(), blacklistWord))
                .ignoreRepeat(false)
                // 各种其他配置
                .enableNumCheck(false)
                .enableEmailCheck(false)
                .enableUrlCheck(false)
                .numCheckLen(3000)
                .init();
    }

}
